<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="css/listings.css">
    <link rel="shortcut icon" href="image/listings_img/favicon.ico" type="image/x-icon">
    <!-- 富文本编辑器js -->
    <script type="text/javascript" charset="utf-8" src="Ueditor\ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="Ueditor\editor_api.js"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="Ueditor/lang/zh-cn/zh-cn.js"></script>
    <title>编辑列表</title>
</head>

<body style="overflow-x: hidden">
    <div class="listings-head">
        <div class="head-l fz16 c999 pinl30">
            列出您的房产
        </div>
        <div class="head-r fz16 c999 pinl30">
            预览列表
        </div>
    </div>
    <div class="listings-body">
        <div class="body-l">
            <div class="lists linh">清单</div>
            <a>
                <div class="Unselected linh edit location">位置</div>
            </a>
            <a>
                <div class="Unselected linh edit txtcen location">基本</div>
            </a>
            <a>
                <div class="Unselected linh edit txtcen location">设施</div>
            </a>
            <a>
                <div class="Unselected linh edit txtcen location">照片</div>
            </a>
            <a>
                <div class="checked linh txtcen location">描述</div>
            </a>
            <a>
                <div class="Unselected linh edit txtcen location">定价</div>
            </a>
        </div>
        <div class="body-r">
            <div class="r-margin">
                <div class="r-r">
                    <div class="r-title">
                        <h3 class="fontw c444">向旅客介绍您的房源</h2>
                            <h5 class="fontw c777">Senseluxury上的每个空间都是独一无二的。突出您的房源受欢迎之处，以便让想要留在您所在地区的房客脱颖而出。</h4>
                    </div>
                    <div class="min-title fz16 c444 martop">
                        <div class="lt-heading-txt">别墅名称</div>
                        <div>
                            <textarea class="lt-heading-area" placeholder="最多 64 个字符" cols="30" rows="10"></textarea>
                        </div>
                    </div>
                    <div class="Ueditor martop">
                        <div class="lt-heading-txt" style="color: #444;font-size: 20px;">别墅详情</div>
                        <iframe src="Ueditor/_examples/completeDemo.html" name="currentif" id="if1"
                            frameborder="0"></iframe>
                    </div>
                    <div class="min-title fz16 c444 martop">
                        <div class="lt-heading-txt">备注</div>
                        <div>
                            <textarea class="lt-heading-area" id="lt2" placeholder="最多64个字符，特别要告诉travlers的东西。" cols="30"
                                rows="10"></textarea>
                        </div>
                    </div>

                    <div class="bottom martop" style="padding-right: 0;">
                        <a href="javascript:history.back(-1)" >
                            <div class="bottompin">返回</div>
                        </a>
                        <div class="bottompin1" id="btnGetValue">下一步</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>

<script src="./jquery/jquery-3.6.0.js"></script>

<script>

    // 获取从url地址截取出来的id
    function getQueryString(name) { //传进想要获取的querystring的key
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURIComponent(r[2]);
        return null;
    };

    // 把JSON对象转化为js对象
    var addvilla = JSON.parse(getQueryString("addvilla"));
    // 获取对象里面的属性
    console.log(addvilla.villa_place);


    // 点击侧边栏按钮
    $(".location").click(function () {

        // 获取富文本编辑器的文本
        var villa_name = $(".lt-heading-area").val();
        console.log(villa_name);

        var myEditor = window.frames["currentif"].UE.getEditor('editor');
        var value = myEditor.getContentTxt();
        console.log(value);

        var remarks = $("#lt2").val();
        console.log(remarks);

        // 添加属性
        addvilla.villa_name = villa_name;
        addvilla.value = value;
        addvilla.remarks = remarks;

        if ($(this).text() == "位置") {
            window.location.href = "listings1.html?addvilla=" + JSON.stringify(addvilla);
        }

        if ($(this).text() == "基本") {
            window.location.href = "listings2.html?addvilla=" + JSON.stringify(addvilla);
        }

        if ($(this).text() == "设施") {
            window.location.href = "listings3.html?addvilla=" + JSON.stringify(addvilla);
        }

        if ($(this).text() == "照片") {
            window.location.href = "listings4.html?addvilla=" + JSON.stringify(addvilla);
        }

        if ($(this).text() == "描述") {
            window.location.href = "listings5.html?addvilla=" + JSON.stringify(addvilla);
        }

        if ($(this).text() == "定价") {
            window.location.href = "listings6.html?addvilla=" + JSON.stringify(addvilla);
        }
    })

    // 下一步

    $("#btnGetValue").click(function () {
        // 获取富文本编辑器的文本
        var villa_name = $(".lt-heading-area").val();
        console.log(villa_name);

        var myEditor = window.frames["currentif"].UE.getEditor('editor');
        var value = myEditor.getContentTxt();
        console.log(value);

        var remarks = $("#lt2").val();
        console.log(remarks);

        // 添加属性
        addvilla.villa_name = villa_name;
        addvilla.value = value;
        addvilla.remarks = remarks;

        window.location.href = "listings6.html?addvilla=" + JSON.stringify(addvilla);
        // alert("嘻嘻嘻");
    })

</script>